package com.hxk.di.controller;

import com.hxk.di.service.BookService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

@Controller
public class BookResourceController {

    //@Qualifier("bookService")
    //@Resource(name="bookService1")//设置要注入的名称
    @Resource//默认按照名称（bookService2）找，如果找到多个在没有设置@Qualifier和@Primary情况下会报找到多个实例的异常
    private BookService bookService2;

    @Override
    public String toString() {
        return "BookResourceController{" +
                "bookService=" + bookService2 +
                '}';
    }
}
